<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
		<title>Javascript-How to trim an array object?</title>
		<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js" type="text/javascript"></script>
		
	</head>
	<body>
		<div id="array-trim-demo">
			<h2>How to trim an array object?</h2>
			<h3>Here is my own implementation:</h3>
			<pre class="brush:js;">
			Array.prototype.myExist=function(a){
			    for(var i=0;i < this.length;i++){
			        if(this[i]===a) return true;
			    };
			    return false;
			};
			
			Array.prototype.myTrim=function(){
			    var temp=[];
			    for(var i=0; i < this.length;i++){
			        if(temp.myExist(this[i])) continue;
			        temp.push(this[i]);
			        
			    };
			    return temp;
			};
			
			
			var x=[11,11,12,13,12];
			
			x=x.myTrim();	
			</pre>
		</div>
	</body>
</html>
